package com.woniu.service.imp;/*
 *
 * @author   米雷
 * @Description
 * @Date:create in 17:10 2020-04-08
 *
 * */

import com.woniu.dao.FriendsMapper;
import com.woniu.dto.FriendName;
import com.woniu.pojo.Friends;
import com.woniu.service.FriendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class FriendsServiceImp implements FriendService {

    @Autowired
    FriendsMapper friendsMapper;




    @Override
    public List<FriendName> getFriend(Long id)
    {
        return friendsMapper.getFriends(id);
    }

    @Override
    public String addFriend(Long uid, Long fid)
    {
        Friends friends = new Friends();
        friends.setUserId(uid);
        friends.setFriendId(fid);
        friends.setCreateTime(new Date());
        if (friendsMapper.insert(friends)!=0){
            return "添加成功";
        }else {
            return "添加失败";
        }
    }

    @Override
    public String delFriend(Long uid, Long fid)
    {
        if (friendsMapper.delFriend(uid,fid)!=0){
            return "删除成功";
        }else {
            return "删除失败";
        }
    }
}
